package com.lcredu.springbootusersys.util;

import java.io.File;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Date;

/**
 * @author 黎长容
 * @date 2025-08-16 16:21
 */
public class FileUtil {
    public static String DIRECT = "static" + File.separator + "images" + File.separator + "upload/";

    //文件分层存储
    public static String getDirPath() {
        LocalDateTime now = LocalDateTime.now();
        int year = now.getYear();
        Month month = now.getMonth();
        int day = now.getDayOfMonth();

        // 使用 File.separator 确保跨平台兼容性
        return year + File.separator + month.getValue() + File.separator + day;
    }

    public static String getDirect() {
        return DIRECT + new SimpleDateFormat("yyyy/MM/dd").format(new Date());
    }
}
